home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / amos / amcafext.lha / AMCAF_Examples / VecRotWireGlenz.AMOS / VecRotWireGlenz.amosSourceCode
AMOS Source Code  |  1995-07-14  |  3KB  |  117 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Vec Rot Pos        Turbo Draw
  3. ' *           Amcaf Examples          * Vec Rot Angles     Blitter Clear 
  4. ' *  Vector Rotate Wire + Glenz V1.0  * Vec Rot Precalc    =Qsin   
  5. ' *      Written by Chris Hodges      * =Vec Rot X 
  6. ' *                                   * =Vec Rot Y 
  7. ' ************************************* =Vec Rot Z 
  8. '                          
  9. ' Hide mouse.
  10. Hide 
  11. ' Setup a nice little screen with double buffering 
  12. Screen Open 0,320,256,8,Lowres
  13. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 
  14. ' Special palette! When two lines overlap, they get a brighter colour! 
  15. '         %001,%010,%011,%100,%101,%110,%111 
  16. Palette 0,$444,$444,$AAA,$444,$AAA,$AAA,$FFF
  17. Double Buffer 
  18. Autoback 0
  19. ' Read out, how many coords are used.
  20. Restore COORDS
  21. Read NUMCO
  22. ' Dim one field to keep these coords, and a second for the rotated.
  23. Dim CO(NUMCO,2),RC(NUMCO,1)
  24. ' Now read all coords in.
  25. For A=1 To NUMCO
  26.   Read CO(A,0),CO(A,1),CO(A,2)
  27. Next 
  28. ' Then, get the number of lines the object consists of.
  29. Restore LINES
  30. Read NUMLI
  31. ' Dim a field to hold the startcoord and the endcoord. 
  32. Dim LI(NUMLI,1)
  33. ' Get the datas. 
  34. For A=1 To NUMLI
  35.   Read LI(A,0),LI(A,1)
  36. Next 
  37. ' Set the three angles. Remember that these are non standard angles, 
  38. ' one full rotation is at 1024, not 360! 
  39. AX=0 : AY=512 : AZ=128
  40. ' New: BP contains the bitplane, onto which the Cube should be drawn.
  41. BP=0
  42. Repeat 
  43.   ' Start clearing the plane to be drawn on. 
  44.    Extension_8_121C 0,BP
  45.   ' While the blitter is working, use the time to calculate the rotations. 
  46.   ' Move and set the angles. 
  47.   Add AX,10
  48.   Add AY,8
  49.   Add AZ,11
  50.    Extension_8_1138 AX,AY,AZ
  51.   ' Calculate the distances by using a sine-function and the three angles. 
  52.   POSX= Extension_8_1106(AX,300)
  53.   POSY= Extension_8_1106(AY,300)
  54.   POSZ= Extension_8_1106(AZ,500)+1500
  55.   ' Set the camera positions.
  56.    Extension_8_1122 POSX,POSY,POSZ
  57.   ' Now it's time to compute the matrix. 
  58.    Extension_8_1152 
  59.   ' So let's rotate all coordinates of the field CO()
  60.   For A=1 To NUMCO
  61.     ' Note: You only have to use the vec rot function with parameters once.
  62.     RC(A,0)= Extension_8_1168(CO(A,0),CO(A,1),CO(A,2))+160
  63.     RC(A,1)= Extension_8_1184 +128
  64.   Next 
  65.   ' It's time to finally get the lines to the screen!
  66.   For A=1 To NUMLI
  67.     ' Starting coordinates pair. 
  68.     C1=LI(A,0)
  69.     ' Ending coordinates pair. 
  70.     C2=LI(A,1)
  71.     ' Get the rotated coordinates
  72.     X1=RC(C1,0) : Y1=RC(C1,1)
  73.     X2=RC(C2,0) : Y2=RC(C2,1)
  74.     ' Draw the line on bitplane BP.
  75.      Extension_8_1016 X1,Y1 To X2,Y2, Extension_8_04F8(BP), Extension_8_04F8(BP)
  76.   Next 
  77.   ' Swap the screens to bring the object to view.
  78.   Screen Swap 
  79.   Wait Vbl 
  80.   ' Select next bitplane.
  81.   Add BP,1,0 To 2
  82. Until Inkey$=Chr$(27) or Mouse Key<>0
  83. Screen Close 0
  84. End 
  85. '  1_____2   
  86. ' 5/____/| 
  87. ' | |  |6| 
  88. ' |4|__|_|3  
  89. ' |/___|/
  90. ' 8    7 
  91. COORDS:
  92.   Data 8
  93. ' CUBE 
  94.   Data -100,-100,-100
  95.   Data 100,-100,-100
  96.   Data 100,-100,100
  97.   Data -100,-100,100
  98.   Data -100,100,-100
  99.   Data 100,100,-100
  100.   Data 100,100,100
  101.   Data -100,100,100
  102.  
  103. LINES:
  104.   Data 12
  105. ' CUBE 
  106.   Data 1,2
  107.   Data 2,3
  108.   Data 3,4
  109.   Data 4,1
  110.   Data 5,6
  111.   Data 6,7
  112.   Data 7,8
  113.   Data 8,5
  114.   Data 1,5
  115.   Data 2,6
  116.   Data 3,7
  117.   Data 4,8